@use "sass:math";

.gallery-image {
  &:hover {
    cursor: pointer;
  }
}

@include media-breakpoint-only(lg) {
  .gallery-header-container {
    align-items: center;
    display: flex;
    justify-content: space-between;

    .gallery-header {
      flex: 0 0 75%;
      order: 1;
    }

    .gallery-studio-image {
      flex: 0 0 25%;
      order: 2;
    }
  }
}

.gallery-header {
  flex-basis: auto;
  font-size: 1.5rem;
  margin-top: 30px;

  @include media-breakpoint-down(xl) {
    font-size: 1.75rem;
  }
}

.gallery-subheader {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;

  .date {
    color: $text-muted;
  }

  .resolution {
    font-weight: bold;
  }
}

.gallery-toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  margin-top: 0.5rem;
  padding-bottom: 0.25rem;
  width: 100%;

  .gallery-toolbar-group {
    align-items: center;
    column-gap: 0.25rem;
    display: flex;
    width: 100%;

    &:last-child {
      justify-content: flex-end;
    }
  }
}

#gallery-details-container {
  .tab-content {
    min-height: 15rem;
  }
}

.gallery-card {
  &.card {
    overflow: hidden;
    padding: 0;
    padding-bottom: 1rem;

    @media (max-width: 576px) {
      width: 100%;
    }
  }

  .card-section {
    margin-top: auto;

    a:hover {
      text-decoration: none;
    }
  }

  .card-popovers {
    margin-bottom: 0;
  }

  .card-section-title {
    color: $text-color;
  }

  &-cover {
    position: relative;
  }

  .preview-scrubber {
    top: 0;
  }

  &-image {
    object-fit: contain;
  }
}

.gallery-tabs {
  max-height: calc(100vh - 4rem);

  overflow: auto;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

$galleryTabWidth: 450px;

@media (min-width: 1200px) {
  .gallery-tabs {
    flex: 0 0 $galleryTabWidth;
    max-width: $galleryTabWidth;

    &.collapsed {
      display: none;
    }
  }

  .gallery-divider {
    flex: 0 0 15px;
    max-width: 15px;

    button {
      background-color: transparent;
      border: 0;
      color: $link-color;
      cursor: pointer;
      font-size: 10px;
      font-weight: 800;
      height: 100%;
      line-height: 100%;
      padding: 0;
      text-align: center;
      width: 100%;

      &:active:not(:hover),
      &:focus:not(:hover) {
        background-color: transparent;
        border: 0;
        box-shadow: none;
      }
    }
  }

  .gallery-container {
    flex: 0 0 calc(100% - #{$galleryTabWidth} - 15px);
    height: calc(100vh - 4rem);
    max-width: calc(100% - #{$galleryTabWidth} - 15px);
    overflow: auto;

    &.expanded {
      flex: 0 0 calc(100% - 15px);
      max-width: calc(100% - 15px);
    }
  }
}

.gallery-tabs,
.gallery-container {
  padding-left: 15px;
  padding-right: 15px;
  position: relative;
  width: 100%;
}

@media (min-width: 1200px), (max-width: 575px) {
  .gallery-performers {
    .performer-card {
      width: 15rem;

      &-gallery {
        height: 22.5rem;
      }

      &-image {
        height: 22.5rem;
        width: 15rem;
      }
    }
  }
}

#gallery-edit-details {
  .rating-stars {
    font-size: 1.3em;
    height: calc(1.5em + 0.75rem + 2px);
  }
}

.gallery-cover {
  aspect-ratio: 4 / 3;
  display: block;
  height: auto;
  width: 100%;
}

.gallery-cover img {
  height: auto;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  width: auto;
}

div.GalleryWall {
  display: flex;
  flex-wrap: wrap;
  margin: 0 auto;
  width: 96vw;

  /* Prevents last row from consuming all space and stretching images to oblivion */
  &::after {
    content: "";
    flex: auto;
    flex-grow: 9999;
  }
}

.GalleryWallCard {
  height: auto;
  padding: 2px;
  position: relative;

  $width: 96vw;

  &-landscape {
    flex-grow: 2;
    width: 96vw;
  }

  &-portrait {
    flex-grow: 1;
    width: 96vw;
  }

  .lineargradient {
    background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.3));
    bottom: 100px;
    height: 100px;
    position: relative;
  }

  .preview-scrubber {
    top: 0;
    z-index: 1;
  }

  &-img {
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    width: 100%;

    &.GalleryWallCard-img-contain {
      object-fit: contain;
      object-position: initial;
    }
  }

  &-title {
    font-weight: bold;
  }

  &-footer {
    bottom: 20px;
    padding: 1rem;
    position: absolute;
    text-shadow: 1px 1px 3px black;
    transition: 0s opacity;
    width: 100%;
    z-index: 2;

    @media (min-width: 768px) {
      opacity: 0;
    }

    &:hover {
      .GalleryWallCard-title {
        text-decoration: underline;
      }
    }

    a {
      color: white;
    }
  }

  &:hover &-footer {
    opacity: 1;
    transition: 1s opacity;
    transition-delay: 500ms;

    a {
      text-decoration: none;
    }
  }

  .rating-stars,
  .rating-number {
    position: absolute;
    right: 1rem;
    text-shadow: 1px 1px 3px black;
    top: 1rem;
    z-index: 2;
  }

  .rating-stars {
    .star-fill-0 .unfilled-star {
      display: none;
    }

    .star-fill-10 .unfilled-star,
    .star-fill-20 .unfilled-star,
    .star-fill-25 .unfilled-star,
    .star-fill-30 .unfilled-star,
    .star-fill-40 .unfilled-star,
    .star-fill-50 .unfilled-star,
    .star-fill-60 .unfilled-star,
    .star-fill-70 .unfilled-star,
    .star-fill-75 .unfilled-star,
    .star-fill-80 .unfilled-star,
    .star-fill-90 .unfilled-star {
      visibility: hidden;
    }

    .filled-star {
      filter: drop-shadow(1px 1px 1px #222);
    }
  }
}

div.GalleryWall {
  @mixin galleryWidth($width) {
    height: math.div($width, 3) * 2;

    &-landscape {
      width: $width;
    }

    &-portrait {
      width: math.div($width, 2);
    }
  }

  .GalleryWallCard {
    @media (min-width: 576px) {
      @include galleryWidth(96vw);
    }
  }

  &.zoom-0 .GalleryWallCard {
    @media (min-width: 768px) {
      @include galleryWidth(16vw);
    }
    @media (min-width: 1200px) {
      @include galleryWidth(10vw);
    }
  }

  &.zoom-1 .GalleryWallCard {
    @media (min-width: 768px) {
      @include galleryWidth(24vw);
    }
    @media (min-width: 1200px) {
      @include galleryWidth(16vw);
    }
  }

  &.zoom-2 .GalleryWallCard {
    @media (min-width: 768px) {
      @include galleryWidth(32vw);
    }
    @media (min-width: 1200px) {
      @include galleryWidth(24vw);
    }
  }

  &.zoom-3 .GalleryWallCard {
    @media (min-width: 768px) {
      @include galleryWidth(48vw);
    }
    @media (min-width: 1200px) {
      @include galleryWidth(32vw);
    }
  }
}

.gallery-file-card.card {
  margin: 0;
  padding: 0;

  .card-header {
    cursor: pointer;
  }

  dl {
    margin-bottom: 0;
  }
}

.col-form-label {
  padding-right: 2px;
}

.gallery-select-option {
  .gallery-select-row {
    align-items: center;
    display: flex;
    width: 100%;

    .gallery-select-image {
      background-color: $body-bg;
      margin-right: 0.4em;
      max-height: 50px;
      max-width: 89px;
      object-fit: contain;
      object-position: center;
    }

    .gallery-select-details {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      max-height: 4.1rem;
      overflow: hidden;

      .gallery-select-title {
        flex-shrink: 0;
        white-space: pre-wrap;
        word-break: break-all;
      }

      .gallery-select-date,
      .gallery-select-studio,
      .gallery-select-code {
        color: $text-muted;
        flex-shrink: 0;
        font-size: 0.9rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }

  .gallery-select-alias {
    font-size: 0.8rem;
    font-weight: bold;
    width: 100%;
    word-break: break-all;
  }
}
